package cn.iocoder.yudao.module.trade.scan.dal.mysql;

import cn.iocoder.yudao.framework.business.basic.dao.query.CoreLambdaQueryWrapper;
import cn.iocoder.yudao.framework.business.order.dao.OrderMapper;
import cn.iocoder.yudao.module.trade.scan.dal.dataobject.ScanOrderDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 下线扫码订单 Mapper
 *
 * @author 山野羡民（1032694760@qq.com）
 */
@Mapper
public interface ScanOrderMapper extends OrderMapper<ScanOrderDO> {

    default int selectCountByShopIdAndUserId(Long shopId, Long userId) {
        Long count = selectCount(new CoreLambdaQueryWrapper<ScanOrderDO>()
                .eq(ScanOrderDO::getShopId, shopId)
                .eq(ScanOrderDO::getUserId, userId)
                .eq(ScanOrderDO::getPayed, true));
        if (count == null) {
            return 0;
        }
        return count.intValue();
    }

}
